import java.util.Comparator;
import java.util.TreeSet;

public class ScoreSort {
    public static void main(String[] args) {
    TreeSet<ScoreSort_Stu> ts = new TreeSet<ScoreSort_Stu>(new Comparator<ScoreSort_Stu>() {
        @Override
        public int compare(ScoreSort_Stu s1, ScoreSort_Stu s2) {
            int num = s2.getMath_score() + s2.getChinese_score() - s1.getMath_score()-s1.getChinese_score();
            int ret = num == 0 ? s1.getName().compareTo(s2.getName()) : num;
            return ret;
        }
    });
        ts.add(new ScoreSort_Stu("Jack",60,70));
        ts.add(new ScoreSort_Stu("Rose",65,75));
        ts.add(new ScoreSort_Stu("Tina",80,90));
        ts.add(new ScoreSort_Stu("Li Hua",85,85));
        ts.add(new ScoreSort_Stu("Judy",90,92));
        ts.add(new ScoreSort_Stu("Mark",90,92));
          for(ScoreSort_Stu sss : ts)
              System.out.println(sss.getName() + " , " + sss.getChinese_score() + " , " + sss.getMath_score());
    }
}
